/*
 * winAnimation.java
 *
 * Created on 20. Juni 2007, 10:24
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package DieSiedler;

import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Image;
import java.io.IOException;
import javax.imageio.ImageIO;
import javax.swing.JPanel;

/**
 * Zeigt ein Bild in einem JPanel an
 * @author mannholi
 */

public class ImgScreen extends JPanel{
    
    private int paneX;//=599;
    private int paneY;//=449;
    private int imageX;//=599;
    private int imageY;//=449;
    private Image img=null;
    private String text=null;
    private int textY;
    private int textX;
  
    
    /** Creates a new instance of winAnimation */
    public ImgScreen(Image img, int paneX, int paneY, int imageX, int imageY){
        this.imageX=imageX;
        this.imageY=imageY;
        this.img=img;
        this.setPreferredSize(new Dimension(paneX,paneY));
    }
    
     public ImgScreen(String text, int paneX, int paneY, int textX, int textY){
        this.textX=textX;
        this.textY=textY;
        this.text=text;
        this.setPreferredSize(new Dimension(paneX,paneY));
    }
     
     public ImgScreen(){
         
     }
     
    
    public void setImg(Image img, int paneX, int paneY, int imageX, int imageY){
        this.imageX=imageX;
        this.imageY=imageY;
        this.img=img;
        this.setPreferredSize(new Dimension(paneX,paneY));
        this.repaint();
    }
    
    
    public void setText(String text, int paneX, int paneY, int textX, int textY){
        this.textX=textX;
        this.textY=textY;
        this.text=text;
        this.setPreferredSize(new Dimension(paneX,paneY));
    }
    
    public void paint(Graphics g){
        super.paint(g);
        if(img!=null){
            g.drawImage(img, 0, 0, imageX, imageY, null);
        }else{
            if(text!=null){
                g.drawString(text,textX,textY);
            }
        }
        
    }
}
